import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Button here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Button extends Actor
{
    /**
     * Act - do whatever the Button wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    private final World shift;
    public Button(World action, GreenfootImage i){
    setImage(i);
    shift = action;
    }
    
    public void act() 
    {
        try{
        if(isTouching(MousePointer.class) && Greenfoot.getMouseInfo().getButton() == 1){
        Greenfoot.setWorld(shift);
        }
        }catch(Exception e){}
        
        
    }    
}
